import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;


public class OpenFile {
    String Open(String urlAndNameFile) throws IOException {

        String textInFile = "";

        Scanner in = new Scanner(new File(urlAndNameFile));
        while (in.hasNextLine()) {
            textInFile = textInFile + in.nextLine() + " ";
        }

        StringBuilder builder = new StringBuilder(textInFile);

        for (int i = 0; i < builder.length(); i++) {

            if (builder.charAt(i) == ' ' && builder.charAt(i) == builder.charAt(i - 1)) {
                builder.deleteCharAt(i);
            }
        }

        return textInFile = String.valueOf(builder);
    }

}
